package threadDemo;

/**
 * 测试stop
 */
public class Test9 implements Runnable{

    private boolean tage = true;

    @Override
    public void run() {
        int i = 0;
        while (tage){
            System.out.println("thread" + i++);
        }
    }

    public void stop() {
        this.tage = false;
    }

    public static void main(String[] args) {
        Test9 t = new Test9();
        new Thread(t).start();
        for (int i = 0;i<1000;i++) {
            System.out.println("main " + i);
            if(i==900){
                t.stop();
                System.out.println("线程停止......");
            }
        }
    }

}
